package com.balance.anole.erp.report.dialog;

import java.util.Date;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.nebula.widgets.calendarcombo.CalendarCombo;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

import com.balance.anole.erp.report.util.IReportID;

public class ReportOrderAnalyzeDialog extends Dialog {
	
	private String digioType;
	
	private CalendarCombo text_FromDt;
	private CalendarCombo text_ToDt;
	
	private Date fromDt;
	private Date toDt;
	
	public Date getFromDt() {
		return fromDt;
	}

	public void setFromDt(Date fromDt) {
		this.fromDt = fromDt;
	}

	public Date getToDt() {
		return toDt;
	}

	public void setToDt(Date toDt) {
		this.toDt = toDt;
	}

	public String getDigioType() {
		return digioType;
	}

	public void setDigioType(String digioType) {
		this.digioType = digioType;
	}
	

	public ReportOrderAnalyzeDialog(Shell parentShell,String digioType){
		super(parentShell);
		this.digioType = digioType;
	}
	
	protected Control createDialogArea(Composite parent) {
		Composite area = (Composite)super.createDialogArea(parent);
	
		if(IReportID.RPT_ORDER_001.equals(digioType)){
			
			final GridLayout gridLayout = new GridLayout();
			gridLayout.numColumns = 2;
			area.setLayout(gridLayout);
			
			final Label label_FromDt = new Label(area,SWT.NONE);
			label_FromDt.setText("From");
			label_FromDt.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
			
			text_FromDt = new CalendarCombo(area,SWT.BORDER);
			text_FromDt.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
			
			final Label label_ToDt = new Label(area,SWT.NONE);
			label_ToDt.setText("To");
			label_ToDt.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
			
			text_ToDt = new CalendarCombo(area,SWT.BORDER);
			text_ToDt.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
		}
		
		return area;
	}
	
	protected void okPressed() {
		setReturnCode(OK);
		
		if(text_FromDt.getDate()!=null){
			fromDt = text_FromDt.getDate().getTime();
		}
		
		if(text_ToDt.getDate()!=null){
			toDt = text_ToDt.getDate().getTime();
		}

		close();
	}

}
